<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html" xmlns:constants="http://www.tuanzi.com/constants/tags">


    <div class="topbar clearfix"
         style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
        <p:toolbar>
            <f:facet name="right">
                <p:commandButton value="新增" icon="fa fa-plus"
                                 actionListener="#{firstPartyTagInfoBean.onAddSubProduct}"
                                 update="subProductDialog"
                                 oncomplete="PF('subProductDialog').show()"
                                 disabled="#{firstPartyTagInfoBean.isView()}"
                />
            </f:facet>
        </p:toolbar>
    </div>

    <div class="ui-fluid" style="padding-top: 30px; width: 100%">
        <div class="card">

            <p:dataTable id="subProductInfoDataTable"
                         style="width: 100%"
                         var="productInfo"
                         value="#{firstPartyTagInfoBean.$.subProducts}"
                         rows="#{constants:get('ROWS')}"
                         lazy="true"
                         paginator="true"
                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                         scrollable="true"
                         scrollWidth="97%"
                         reflow="true"
                         resizableColumns="true">

                <p:column headerText="操作">
                    <p:splitButton icon="fa fa-eye"
                                   action="#{firstPartyTagInfoBean.onEditSubProduct(productInfo.id)}"
                                   update="@form"
                                   oncomplete="PF('subProductDialog').show()"
                                   process="@this">

                        <p:menuitem value="删除" icon="fa fa-remove"
                                    action="#{firstPartyTagInfoBean.onDeleteSubProduct(productInfo.id)}"
                                    process="@this" update="@form:tabView:subProductInfoDataTable"

                        />

                    </p:splitButton>
                </p:column>
                <p:column headerText="ID">
                    <h:outputText value="#{productInfo.id}"/>
                </p:column>
                <p:column headerText="甲方名称">
                    <h:outputText value="#{productInfo.name}"/>
                </p:column>
                <p:column headerText="甲方icon">
                    <p:graphicImage url="#{productInfo.logo}" width="50px"/>
                </p:column>
                <p:column headerText="最后更新人">
                    <h:outputText value="#{productInfo.updator}"/>
                </p:column>
                <p:column headerText="更新时间">
                    <h:outputText value="#{productInfo.updateTime}">
                        <f:convertDateTime pattern="#{constants:get('DATETIME_FORMAT')}"/>
                    </h:outputText>
                </p:column>
                <p:column headerText="创建时间">
                    <h:outputText value="#{productInfo.createTime}">
                        <f:convertDateTime pattern="#{constants:get('DATETIME_FORMAT')}"/>
                    </h:outputText>
                </p:column>
                <p:column headerText="备注">
                    <h:outputText value="#{productInfo.remark}"/>
                </p:column>
            </p:dataTable>

        </div>
    </div>


    <p:dialog widgetVar="subProductDialog" id="subProductDialog">

        <div class="card" style="width: 500px;height: 350px;">
            <h1>子产品信息</h1>
            <p:panelGrid columns="2"
                         columnClasses="ui-grid-col-2,ui-grid-col-10"
                         layout="grid" styleClass="ui-panelgrid-blank"
                         style="border:0px none; background-color:transparent;" id="subProductPanel">

                <p:outputLabel for="jfname" value="甲方名称"/>
                <p:inputText id="jfname" value="#{firstPartyTagInfoBean.selectedSubProduct.name}"
                             disabled="#{firstPartyTagInfoBean.isView()}"/>


                <p:outputLabel for="icon" value="甲方icon"/>

                <p:outputPanel>

                    <p:graphicImage id="icon" url="#{firstPartyTagInfoBean.selectedSubProduct.logo}" width="80"/>

                    <p:fileUpload style="width: 100px"
                                  fileUploadListener="#{firstPartyTagInfoBean.onUploadSubProductLogo}"
                                  mode="advanced"
                                  fileLimit="1"
                                  auto="true" fileLimitMessage="只能上传一个文件" invalidFileMessage="不支持上传文件类型"
                                  invalidSizeMessage="文件过大" sizeLimit="#{constants:get('UPLOAD_FILE_SIZE')}"
                                  allowTypes="/(\.|\/)(#{constants:get('UPLOAD_FILE_SUFFIX')})$/" label="上传"
                                  update="subProductPanel"
                                  process="@form"
                                  disabled="#{firstPartyTagInfoBean.isView()}"/>

                </p:outputPanel>

                <p:outputLabel for="jfremark" value="备注"/>
                <p:inputTextarea id="jfremark"
                                 value="#{firstPartyTagInfoBean.selectedSubProduct.remark}"
                                 disabled="#{firstPartyTagInfoBean.isView()}"/>

                <p:commandButton value="保存" icon="fa fa-search"
                                 process="@form"
                                 update="@form:tabView:subProductInfoDataTable"
                                 actionListener="#{firstPartyTagInfoBean.onSaveSubProduct}"
                                 disabled="#{firstPartyTagInfoBean.isView()}"/>

            </p:panelGrid>
        </div>

    </p:dialog>


</ui:composition>